/**
 *  (c)
 * <p>
 *
 * <p>
 *
 */

package com.nn.smart.bus.feign;

import com.nn.smart.bus.commons.tools.security.user.UserDetail;
import com.nn.smart.bus.dto.DataScopeDeptList;
import com.nn.smart.bus.dto.SysUserOpenIdFormDTO;
import com.nn.smart.bus.feign.fallback.UserFeignClientFallback;
import com.nn.smart.bus.commons.tools.constant.ServiceConstant;
import com.nn.smart.bus.commons.tools.utils.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * 用户接口
 *
 * @author nanning
 * @since 1.0.0
 */
@FeignClient(name = ServiceConstant.BUS_ADMIN_SERVER, fallback = UserFeignClientFallback.class, contextId = "UserFeignClient")
public interface UserFeignClient {

    /**
     * 根据用户ID，获取用户信息
     */
    @GetMapping("sys/user/getById")
    Result<UserDetail> getById(@RequestParam("id") Long id);

    /**
     * 根据用户名，获取用户信息
     *
     * @param username 用户名
     */
    @GetMapping("sys/user/getByUsername")
    Result<UserDetail> getByUsername(@RequestParam("username") String username);

    /**
     * 根据用户ID获取用户角色权限信息
     *
     * @return com.nn.smart.bus.commons.tools.utils.Result<com.nn.smart.bus.dto.DataScopeDeptList>
     * @params [id]
     * @author nanning
     * @since 2019/11/19 23:31
     */
    @GetMapping("sys/user/getDataScope")
    Result<List<DataScopeDeptList>> getDataScopeList(@RequestParam("id") Long id);

    /**
     * 根据用户名更新用户微信openId
     *
     * @return com.nn.smart.bus.commons.tools.utils.Result
     * @params [sysUserOpenIdFormDto]
     * @author nanning
     * @since 2019/11/20 9:52
     */
    @PostMapping("sys/user/modifyOpenId")
    Result modifyOpenIdByUsername(SysUserOpenIdFormDTO sysUserOpenIdFormDto);

    /**
     * 组装用户部门层级结构
     *
     * @param userId
     * @return com.nn.smart.bus.commons.tools.utils.Result
     * @author nanning
     */
    @GetMapping("sys/user/packageOption/{userId}")
    Result packageUserDeptOption(@PathVariable("userId") Long userId);

    /**
     * 退出登录
     *
     * @return com.nn.smart.bus.commons.tools.utils.Result
     * @params userId
     * @author nanning
     */
    @GetMapping("sys/user/updateUserOpenId/{userId}")
    Result updateUserOpenId(@PathVariable("userId") Long userId);

    /**
     * @Description  根据临时凭证获取用户信息
     * @author nanning
     * @Date  2020/6/22
     * @Param [scrip]
     * @return com.nn.smart.bus.commons.tools.utils.Result<com.nn.smart.bus.commons.tools.security.user.UserDetail>
     **/
    @GetMapping("sys/user/getByScrip/{scrip}")
    Result<UserDetail> getByScrip(@PathVariable("scrip") String scrip);

}
